package com.sky.controller.admin;

import com.sky.dto.DishInventoryPageQueryDTO;
import com.sky.dto.DishStockDTO;
import com.sky.result.PageResult;
import com.sky.result.Result;
import com.sky.service.DishInventoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Delete;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 库存管理
 */
@RestController
@RequestMapping("/admin/Inventory")
@Slf4j
@Api(tags = "库存管理接口")
public class DishInventoryController {

    @Autowired
    private DishInventoryService dishInventoryService;

    /**
     * 库存分页查询
     * @param dishInventoryPageQueryDTO
     * @return
     */
    @GetMapping("/page")
    @ApiOperation("库存分页查询")
    public Result<PageResult> page(DishInventoryPageQueryDTO dishInventoryPageQueryDTO){
        log.info("库存分页查询:{}"+dishInventoryPageQueryDTO);
        PageResult pageResult=dishInventoryService.pageQuery(dishInventoryPageQueryDTO);
        return Result.success(pageResult);
    }

    /**
     * 修改库存量
     * @param dishStockDTO
     * @return
     */
    @PutMapping("/stock")
    @ApiOperation("修改库存量")
    public Result updateStock(@RequestBody DishStockDTO dishStockDTO){
        log.info("修改库存量:{}"+dishStockDTO);
        dishInventoryService.update(dishStockDTO);
        return Result.success();
    }

    @DeleteMapping("/{dishId}")
    @ApiOperation("删除库存信息")
    public Result delete(@PathVariable Long dishId){
        return Result.success();
    }


}
